package com.evola.dbsm.view.navigation
{
	import com.evola.dbsm.model.ProjectBean;
	import com.evola.dbsm.model.ScriptBean;
	
	import flash.display.DisplayObject;
	import flash.events.MouseEvent;
	
	import spark.components.NavigatorContent;
	
	[Bindable]
	public class NavigationPresenter 
	{
		
		public var view : NavigationView;
		public var model : NavigationModel = new NavigationModel();
		
		public function NavigationPresenter(){
			
		}
		
		public function showProjects() : void{
			
			selectView(NavigationModel.VIEW_PROJECTS);	
			
			Presenters.projectListPresenter.init();
		}
		
		public function showProject(project : ProjectBean) : void{
			
			selectView(NavigationModel.VIEW_PROJECT_SCRIPTS);
			
			Presenters.scriptListPresenter.init(project);
		}
		
		public function showScript(script : ScriptBean) : void{
			
			selectView(NavigationModel.EDIT_SCRIPT);
			
			Presenters.scriptEditPresenter.edit(Presenters.scriptListPresenter.model.project, script);
		}
		
		public function addScript() : void{
			
			selectView(NavigationModel.EDIT_SCRIPT);
			
			Presenters.scriptEditPresenter.add(Presenters.scriptListPresenter.model.project);
		}
		
		public function editProject() : void{
			
			selectView(NavigationModel.EDIT_PROJECT);
			
			Presenters.projectEditPresenter.editProject(Presenters.scriptListPresenter.model.project);
		}
		
		private function selectView(viewName : String) : void{
			
			model.selectView(viewName);
		}

	}
}